<?php

// no direct access
defined('_JEXEC') or die('Restricted access');
require_once (dirname(__FILE__).DS.'helper.php');
require_once (dirname(__FILE__).DS.'olimage.php');
JPluginHelper::importPlugin('content', null, false);


JHTML::script('modules/'.$module->module.'/assets/ol.shownews.js');

$helper = new modOLshowNewsHelper();
//image settings
$helper->iwidth 		= 	intval (trim( $params->get( 'iwidth', 152 ) ));
$helper->iheight 		= 	intval (trim( $params->get( 'iheight', 200 ) ));
// asign variables
$moduleID     = 'olsn-modid' . $module->id;
$xheight = $params->get('xheight');
$delaytime 		= intval( $params->get( 'delaytime', 10 ) );
$order =  $params->get( 'sort_order_field' ,'created' );
$cache = (bool) $params->get('enable_cache',1);
// get list of articles.
$source = $helper->getList( $params );
if(empty($source))
{
$source = array();
} 
$total = count($source); 
// sort articles without sql query
$list = $cache &&  $total > 0 && trim($order) == 'rand' ? array_flip(array_rand($source, $total)) : array_keys($source);
// render for layout.
require( JModuleHelper::getLayoutPath( $module->module ) ) ;

unset($list);
unset($source);
if($total > 0):
?>
<script type="text/javascript">	
$(window).addEvent( 'domready', function(){
var options = new Class({
initialize: function(){

},
wrapper:$("ol-shownews-<?php echo $moduleID; ?>"),
mode:'<?php echo $params->get('animation', 'scroll_left'); ?>',
interval:<?php echo (int)$params->get('animationtime', 1000); ?>,
delayTime:<?php echo (int)$delaytime * 1000; ?>,
fxOptions : { duration: <?php echo $params->get('animation_speed', 1000);?>,
transition: <?php echo $params->get('animation_transition', 'Fx.Transitions.linear'); ?> ,
wait: false }	
});
var olShowNewsModid<?php echo $module->id; ?> = new OLShowNews( options );
} );
</script>
<?php endif; ?>